package com.shsh.safemanage.model;

import java.io.Serializable;
import java.util.List;

import com.shsh.safemanage.util.Util;

/**
 * 
 * 
 * @author user
 * 
 */
public class PostcheckDepartMonthCheckSummaryReport implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 5013238408765809878L;
	/**
	 *
	 */
	private Long gradeSum;
	/**
	 *
	 */
	private Integer problemCount;

	private Integer closedCount;

	private Long depart1ID;
	private String depart1Name;

	private List<PostcheckDepartMonthCheckSummaryRow> rowList;

	private int year;
	private int month;

	private Long problemID;

	/**
	 * 
	 * 
	 * @return
	 */
	public Long getPenaltySum() {
		return gradeSum == null ? 0 : gradeSum * 100;
	}

	public Long getGradeSum() {
		return gradeSum;
	}

	public void setGradeSum(Long gradeSum) {
		this.gradeSum = gradeSum;
	}

	public Integer getProblemCount() {
		return problemCount;
	}

	public void setProblemCount(Integer problemCount) {
		this.problemCount = problemCount;
	}

	public List<PostcheckDepartMonthCheckSummaryRow> getRowList() {
		return rowList;
	}

	public void setRowList(List<PostcheckDepartMonthCheckSummaryRow> rowList) {
		this.rowList = rowList;
	}

	public Integer getClosedCount() {
		return closedCount;
	}

	public void setClosedCount(Integer closedCount) {
		this.closedCount = closedCount;
	}

	public Long getDepart1ID() {
		return depart1ID;
	}

	public void setDepart1ID(Long depart1ID) {
		this.depart1ID = depart1ID;
	}

	public String getDepart1Name() {
		return depart1Name;
	}

	public void setDepart1Name(String depart1Name) {
		this.depart1Name = depart1Name;
	}

	public int getYear() {
		return year;
	}

	public void setYear(int year) {
		this.year = year;
	}

	public int getMonth() {
		return month;
	}

	public void setMonth(int month) {
		this.month = month;
	}

	public Long getProblemID() {
		return problemID;
	}

	public void setProblemID(Long problemID) {
		this.problemID = problemID;
	}

	private Problem findProblemByID(Long problemID) {
		for (PostcheckDepartMonthCheckSummaryRow row : rowList) {
			for (Problem p : row.getProblemList()) {
				if (p.getId() != null && p.getId().equals(problemID)) {
					return p;
				}
			}
		}
		return null;
	}

	public void setCloseFeedback(Long problemID, String closeFeedback) {
		Problem p = findProblemByID(problemID);
		if (p != null) {
			p.setCloseFeedback(Util.isoToUTF8(closeFeedback));
		}
	}

	public void setIsClosed(Long problemID, Boolean isClosed) {
		Problem p = findProblemByID(problemID);
		if (p != null) {
			p.setIsClosed(isClosed);
		}
	}

}
